#pragma once
#include "Cube.h"
#include "Ray.h"

using namespace std;

class VONode
{
private:
	VONode * data[8];
	Vector3d minv,maxv,medv;
	double size;
	Cube cube;
public:
	VONode(Vector3d minimum,Vector3d maximum);
	~VONode(void);
	void create(int i,bool x,bool y,bool z)
	{
		if(data[i] != 0) return;
		Vector3d minn,maxn;
		
		//true means <
		if(!x)
		{
			minn.x = minv.x;
			maxn.x = medv.x;
		}
		else
		{
			minn.x = medv.x;
			maxn.x = maxv.x;
		}

		if(!y)
		{
			minn.y = minv.y;
			maxn.y = medv.y;
		}
		else
		{
			minn.y = medv.y;
			maxn.y = maxv.y;
		}

		if(!z)
		{
			minn.z = minv.z;
			maxn.z = medv.z;
		}
		else
		{
			minn.z = medv.z;
			maxn.z = maxv.z;
		}
		//cout << i << "\n";
		data[i] = new VONode(minn,maxn);
	}
	void set(int x,int z,int y);
	bool empty();
	TraceResult hit(const Ray &ray);
};

